# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=libusbmuxd
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.1.0
pkgrel=1
pkgdesc='A client library to multiplex connections from and to iOS devices (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.libimobiledevice.org/'
msys2_repository_url="https://github.com/libimobiledevice/libusbmuxd"
msys2_references=(
  "cpe: cpe:/a:libimobiledevice:libusbmuxd"
)
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-libimobiledevice-glue"
         "${MINGW_PACKAGE_PREFIX}-libplist")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/libimobiledevice/libusbmuxd/releases/download/${pkgver}/${_realname}-${pkgver}.tar.bz2"
        001-no-static-linking.patch
        002-export-symbols.patch)
sha256sums=('c35bf68f8e248434957bd5b234c389b02206a06ecd9303a7fb931ed7a5636b16'
            '220963007a583a4b0c5ae886fca57b5b68c52d74bfa275cfa44f2fbcda371406'
            'd079b3f8e0ebb0019c9d9d33b20c7a8a9f907a1bce38018e4837ed3befffbad2')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/001-no-static-linking.patch
  patch -p1 -i "${srcdir}"/002-export-symbols.patch

  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  export lt_cv_deplibs_check_method='pass_all'

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${MSYSTEM}
  make check
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make install DESTDIR="${pkgdir}"
}
